﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpDbCommonEdit.h"
#include "IObject.h"

namespace gcmp
{
    class IDocument;
    class UniIdentity;
    class IElement;
    class IElementTrimStrategy;

    /// \brief Trim/Extend 管理接口
    ///
    FINAL_INTERFACE class GCMP_DB_COMMON_EDIT_EXPORT ICommonEditTrimManager
    {
    public:
        /// \brief 析构函数
        virtual ~ICommonEditTrimManager() {}

        /// \brief 获取全局唯一实例
        static ICommonEditTrimManager* Get();

        /// \brief 添加Trim/Extend策略
        ///
        /// \param elementImplementationUid Element实现类别的Uid
        /// \param opElementTrimStrategy 策略对象
        /// \return 如果添加成功返回true，否则false
        virtual bool AddStrategy(const UniIdentity& elementImplementationUid, OwnerPtr<IElementTrimStrategy> opElementTrimStrategy) = 0;

        /// \brief 删除Trim/Extend策略
        ///
        /// \param elementImplementationUid Element实现类别的Uid
        /// \return 如果删除成功返回true，否则false
        virtual bool DeleteStrategy(const UniIdentity& elementImplementationUid) = 0;

        /// \brief 获取Trim/Extend策略
        ///
        /// \param elementImplementationUid Element实现类别的Uid
        /// \return Trim/Extend策略对象
        virtual IElementTrimStrategy* GetStrategy(const UniIdentity& elementImplementationUid) = 0;

        /// \brief 获取Trim/Extend策略
        ///
        /// 获取Element的Uid来对应的Trim/Extend策略对象，如果没有，则找其最近父节点的Trim/Extend策略对象
        /// \param elementImplementationUid Element实现类别的Uid
        /// \return Trim/Extend策略对象
        virtual IElementTrimStrategy* GetOrFindParentStrategy(const IElement* pElement) = 0;
    };
}
